begintalkscript;

variables;

begintalknode 1;
state = -1;
nextstate = 1;
question = "Smiley Guard";
text1 =  "The smiley looks you over from top to bottom. _You must be the humans! King Smiley is expecting you._";

begintalknode 2;
state = 1;
nextstate = 2;
question = "Where is King Smiley?";
text1 = "_King Smiley is in the Throne Room. He is waiting for you._";

begintalknode 3;
state = 2;
nextstate = -1;
question = "What does King Smiley want?";
text1 = "_I don't know. You should see him._";

begintalknode 4;
state = 1;
nextstate = -1;
question = "Who are you?";
text1 = "_That doesn't matter. Nothing matters until you talk to King Smiley._";

begintalknode 5;
state = -1;
nextstate = 3;
question = "Bookworm";
text1 = "_Hello,_ mumbles the smiley face, not looking up from its reading. _My name is (mumble). I like to read as you can (mumble). Now, would you please (mumble) me to my (mumble)ing?_";

begintalknode 6;
state = 3;
nextstate = -1;
question = "What are you reading?";
text1 = "_(Mumble)._";

begintalknode 7;
state = 3;
nextstate = -1;
question = "Could you speak up?";
text1 = "_And why the (mumble) should I do that, you (mumble)ing (mumble)?_";

begintalknode 8;
state = -1;
nextstate = 4;
question = "King Smiley";
text1 = "_Welcome to the Smiling Keep!_ booms King Smiley. _I am King Smiley!_";
text2 = "_You have been brought here because you will be a great asset in our war against the Frowneys._ He spits the last word, as if it tastes bad.";

begintalknode 9;
state = 4;
nextstate = 5;
question = "Who are the 'Frowneys'?";
text1 = "_They are the enemy._";
text2 = "_They scorn happiness._";
text3 = "_They attack us!_";
text4 = "_They must learn to embrace happiness, and we will make it happen._";

begintalknode 10;
state = 5;
nextstate = 6;
question = "How will we make them 'embrace happiness'?";
text1 = "_We will give them a peace offering._";

begintalknode 11;
state = 6;
nextstate = -1;
question = "Elaborate.";
text1 = "_Go to the other side of the Lava River. There is a secret passage to the Frowney keep. Deliver the Peace Offering, and return._";
code =
	set_flag(1,5,1);
	set_terrain(42,21,33);
	toggle_quest(0,1);
break;

begintalknode 13;
state = 4;
nextstate = -1;
condition = get_flag(1,3) == 1;
question = "Can you tell the Mage I am trustworthy?";
text1 = "_Ah, yes, him. I will have him informed that you are trustworthy._";
code = 
	set_flag(1,6,1);
break;

begintalknode 14;
state = -1;
nextstate = 10;
question = "Guard";
text1 = "_You've talked to King Smiley? Then why are you here?! Go!_";
code =
	end();
break;

begintalknode 15;
state = -1;
nextstate = 8;
question = "Mage";
text1 = "_What do you want?_ asks the Smiley Mage.";

begintalknode 16;
state = 8;
nextstate = -1;
question = "Can you teach me magic?";
text1 = "You conclude your training with the Smiley Mage.";
code = 
	 begin_shop_mode("Smiley Mage's Spells","The Smiley Mage has agreed to train you in magic.",6,4,4);
break;

begintalknode 17;
state = 8;
nextstate = -1;
question = "What do you do here?";
text1 = "_Stare at the beams..._";

begintalknode 18;
state = -1;
nextstate = 9;
question = "Welcomer.";
text1 = "The Smiley Face smiles at you. (Not that it could do anything else.) _Welcome! I am Welcomer! I welcome people._";

begintalknode 19;
state = 9;
nextstate = -1;
question = "...?";
text1 = "_That's right! Welcome!_";
text2 = "Welcomer turns away.";
code = 
	end();
break;

begintalknode 20;
state = -1;
nextstate = 10;
question = "Mage";
text1 = "_What is it that you want?_ asks the Smiley Mage.";

begintalknode 21;
state = 10;
nextstate = -1;
question = "Can you teach me magic?";
text1 = "_I will not share my secrets with you until  I know I can trust you._";
text2 = "The Smiley Mage turns away.";
code =
	end();
break;